import { Component, OnInit,TemplateRef,ViewContainerRef, ViewChild, AfterViewInit} from '@angular/core';

@Component({
  selector: 'app-template-ref',
  templateUrl: './template-ref.component.html',
  styleUrls: ['./template-ref.component.css']
})
export class TemplateRefComponent implements OnInit {

    @ViewChild('tpl') tpl:TemplateRef<any>
    @ViewChild('tpl',{read:ViewContainerRef }) tplVCRref:ViewContainerRef 

    constructor() { }

    ngOnInit() {
    }

    ngAfterViewInit(){
      
        // let embedview=this.tpl.createEmbeddedView(null);
      
        // let commentNode=this.tpl.elementRef.nativeElement;
        // embedview.rootNodes.forEach(node=>{
        //     commentNode.parentNode.insertBefore(node,commentNode.nextSibling);
        // })
        console.log(this.tplVCRref)
        this.tplVCRref.createEmbeddedView(this.tpl)

      
    }

}
